# Admin controller

require 'digest/sha1'

class AController < ApplicationController
  
  layout 'admin'
  before_filter :verify_login


  def index
    @users  = User.find(:all, :order=>'last_login desc, updated_on desc')
    @events = Calendar.find(:all, :order=>'date')
  end

  def verify_login
    return if session['admin'] != nil

    # change the pwd hash to suit your need
    if params['l'] != nil and Digest::SHA1.hexdigest(params['l']['l'])=='e81fe20d2df326dfbe5e6e3b592aa18929208c9b'
      session['admin'] = 0
      redirect_to :action=>:index
    else
      render :action=>:login
    end

  end
  
  
  def login

  end
  
end
